package com.kuang.boot.dao;

import com.kuang.boot.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Repository
//部门dao
public class DepartmentDao {
//模拟数据库中的数据
    private static Map<Integer, Department> departmentMap = null;

    static {
        departmentMap = new HashMap<Integer, Department>();//创建一个部门表

        departmentMap.put(1001,new Department(101,"教学部"));
        departmentMap.put(1002,new Department(102,"市场部"));
        departmentMap.put(1003,new Department(103,"教研部"));
        departmentMap.put(1004,new Department(104,"运营部"));
        departmentMap.put(1005,new Department(105,"后勤部"));

    }

//    获得所有部门信息
    public Collection<Department> getDepartment(){
        return departmentMap.values();
    }
//    通过id得到部门
    public Department getDepartmentById (Integer id){
        return departmentMap.get(id);
    }
}
